<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>
        <ui:composition template="./../../Template/generalTemplate.xhtml">
            <ui:define name="content">
                <h:form id="form" prependId="false"  >
                    <p:growl id="growl" showDetail="true" />
                    <p:panel id="hah" header="Create Product Batch Record" style="height:495px;">
                        <div style="margin-top:20px;margin-left:50px;margin-right:50px;">

                            <br /><br />

                            <p:dataTable  id="addLine" value="#{createRecordManagedBean.productRecordList}" var="productRecordList">
                                <p:column >
                                    <f:facet name="header">Product Name</f:facet>
                                    #{productRecordList.productInventoryLevel.product.productName}
                                </p:column>

                                <p:column>
                                    <f:facet name="header">Manufacture Date</f:facet>
                                    <h:outputText value="#{productRecordList.manufactureDate}">
                                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                                    </h:outputText>
                                </p:column>

                                <p:column>
                                    <f:facet name="header" >Batch Quantity</f:facet>
                                    #{productRecordList.quantity}
                                </p:column>

                                <p:column>
                                    <f:facet name="header" >Warehouse Location</f:facet>
                                    #{productRecordList.warehouseLocation}
                                </p:column>

                                <p:column>
                                    <f:facet name="header">Action</f:facet>
                                    <h:commandLink value="Delete"   action="#{createRecordManagedBean.deleteProductRecord(productRecordList)}"/>  

                                </p:column>

                            </p:dataTable>
                            <br />
                            <p:commandButton value="Submit" update="growl" actionListener="#{createRecordManagedBean.submitRecord}"/>
                            

                            <div style="position:absolute;top:450px;">

                                <p:panel header="Add New Record" toggleable="true">
                                    <table>

                                        <tr><td width="280"><h:outputText value="Choose Product:    "/></td>
                                         <td width="180"><h:outputText value = "Manufacture Date   "/></td>
                                        <td width="150"><h:outputText value = "Batch Quantity "  /></td>
                                         <td><h:outputText value="Warehouse Location   "/></td></tr>
                                        <td><h:selectOneMenu id="productType"   required="true" value="#{createRecordManagedBean.productName}" >
                                                <f:selectItem itemLabel="Select Product..." itemValue="" />
                                                <f:selectItems value="#{createRecordManagedBean.getProductNames()}"  />
                                            </h:selectOneMenu>
                                        </td>

                                       
                                        
                                        <td> <p:calendar value="#{createRecordManagedBean.productBatchRecord.manufactureDate}"   pattern="yyyy-MM-dd" /> 
                                        </td>

                                        
                                        <td> <h:inputText value="#{createRecordManagedBean.productBatchRecord.quantity}"  style="width:120px;"  /> 
                                        </td>

                                      
                                        <td><h:selectOneMenu id="warehouseLocaiton"   style="width:180px;" required="true" value="#{createRecordManagedBean.productBatchRecord.warehouseLocation}" >
                                                <f:selectItem  itemLabel="Please select.." noSelectionOption="true"/>
                                                <f:selectItem   itemValue="Sector A" itemLabel="Sector A"/>
                                                <f:selectItem   itemValue="Sector B" itemLabel="Sector B"/>
                                                <f:selectItem   itemValue="Sector C" itemLabel="Sector C"/>
                                                <f:selectItem  itemValue="Sector D" itemLabel="Sector D"/>
                                            </h:selectOneMenu>
                                        </td>
                                        <td><p:commandButton value="Add" actionListener="#{createRecordManagedBean.addProductRecord}" update="addLine statusMessages" ajax="true"    >

                                            </p:commandButton></td>
                                        
                                    </table>
                                    
                                </p:panel>
                                 

                                <p:messages id="statusMessages"/>
                            </div>
                        </div>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>


    </body>
</html>
